/**
 * ClassName: Exer0604
 * Package: PACKAGE_NAME
 * Description:清除字符串中的0
 *
 * @Author fjorid
 * @Create 2025/2/25 20:58
 * @Version 1.0
 */
public class Exer0604 {
    public static void main(String[] args) {

        String original = "java技术学习班20070326";

        char charToRemove = '0';

        String result = removeChar(original, charToRemove);
        System.out.println("清除指定字符后的字符串: " + result);
    }

    public static String removeChar(String str, char target) {

        StringBuilder newStr = new StringBuilder();

        for (int i = 0; i < str.length(); i++) {

            char current = str.charAt(i);

            if (current != target) {

                newStr.append(current);
            }
        }

        return newStr.toString();
    }
}
